#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e6 + 10;

int n, m, K;
int gra[N];
bool vis[N];

vec G[N];

int dis[N];

int main() {
#ifdef YJR_2333_TEST
	freopen("1.in", "r", stdin);
#endif
	n = in, m = in, K = in;
	rep(i, 1, m) {
		int x = in, y = in;
		G[x].eb(y), G[y].eb(x);
	}
	memset(dis, 0x3f, sizeof(dis));
	priority_queue < pii, vector < pii >, greater < pii > > pot;
	rep(i, 1, K) {
		int p = in, h = in;
		dis[p] = N - h - 1;
		pot.ep(dis[p], p);
	}
	while(pot.size()) {
		int x = pot.top().se; pot.pop(); if(vis[x]) continue; vis[x] = true;
		for(auto y : G[x]) if(dis[y] > dis[x] + 1) dis[y] = dis[x] + 1, pot.ep(dis[y], y);
	}
	vec ans;
	rep(i, 1, n) if(dis[i] < N) ans.eb(i);
	printf("%d\n", ans.size());
	for(auto v : ans) printf("%d ", v); puts("");
	return 0;
}
